{include file="common/head"}
<head>
<title>部门新增</title>
<style type="text/css">
  .form-label{width:140px;}
  .form-control{width:60%;display: inline-block;}
</style>

</head>
<body >
    <div class="container p-3 my-3 " style="max-width: 600px;"  >
    <h2>部门新增</h2>
    <form method="post" action="/index.php/dept/dept_add" enctype="multipart/form-data">

      <div class="mb-3">
        <label for="fid" class="form-label">所属部门:</label>
        <select id="fid" name="fid" class="form-control">
            {foreach $dept as $k=>$v}
                <option value="{$k}" >{$v['name']}</option>
            {/foreach}
        </select>
      </div>

      <div class="mb-3">
        <label for="type" class="form-label">部门类型:</label>
        <input type="radio" class="form-check-input" id="radio1" name="type" value="1"  checked /> 
        <label class="form-check-label" for="radio1">普通部门</label>
        <input type="radio" class="form-check-input" id="radio2" name="type" value="2" />
        <label class="form-check-label" for="radio2">外部合作</label>
      </div>
      <div class="mb-3">
        <label for="title" class="form-label">部门名称:</label>
        <input type="text" class="form-control" id="name" name="name" value="" placeholder="name" />
      </div>
      <div class="mb-3">
        <label for="title" class="form-label">说明:</label>
        <input type="text" class="form-control" id="title" name="title" value="" placeholder="title" />
      </div>
      <div class="mb-3">
        <label for="user_id" class="form-label">负责人:</label>
        <div class="input-group form-control">
          <input type="hidden"  id="user_id" name="user_id" value="" /></c>
          <input type="text" class="form-control" id="user_id_name" value="" placeholder="姓名或者手机号码" style="width:200px;" /></c>
          <button type="button" id="find_user" class="btn btn-info  bi-search" >负责人</button>
        </div>
      </div>        
      <div class="mb-3">
        <label for="mobile" class="form-label">联系电话:</label>
        <input type="text" class="form-control" id="mobile" name="mobile" value="" placeholder="mobile" />
      </div>

      <div class="mb-3">
        <img src="" style="width: 200px;"/><br />
        <label for="shop_img" class="form-label">logo:</label>
        <input type="file"  name="shop_img" />
      </div>
         
      <div class="mb-3">
        <label for="status" class="form-label">是否开启:</label>
          <input type="radio" class="form-check-input" id="radio3" name="status" value="1"  checked /> 
          <label class="form-check-label" for="radio3">开启</label>
          <input type="radio" class="form-check-input" id="radio4" name="status" value="2" />
          <label class="form-check-label" for="radio4">关闭</label>
       </div>

      <button  type="button" class="btn btn-primary" onclick="doSave()">保存(Save)</button>

    </form>
    </div>

<script type="text/javascript">
    $(function(){
      $("#find_user").on('click',function(){
        $.post('/index.php/user/getOne',{nameOrMobile:$("#user_id_name").val()},function(res){
          if(res.code){
            var data = res.data;
            var user_id = data.id;
            $("#user_id").val(user_id);
            layer.msg(res.msg);
          }else{
            layer.msg(res.msg);
          }

        })
      })

    })
    
    function doSave(){

      if(!$("#name").val()) {
        layer.msg("无效的名称(Invalid name)!");
        return 0;
      }    
      //询问框
      layer.confirm('是否确定保存?', {
        btn: ['YES','CANCEL'] //按钮
      }, function(){
        $('form').submit();
      }, function(){
        layer.msg("Cancel!");
        return 0;
      });
    }

</script>


</body>
</html>
